#include <cstdio>

#define INC(x, y) (x = (x+y)%p)

using namespace std;

typedef long long ll;
const int maxn=100;
ll f[maxn+1][maxn*maxn+1], fact[maxn*maxn+1], invf[maxn*maxn+1];
int n, p;

ll qpow(ll a, int n) {
    ll s=1;
    for (; n; n/=2) {
        if (n&1) s=s*a%p;
        a=a*a%p;
    }
    return s;
}

void initFact(int n) {
    fact[0] = 1;
    for (int i=1; i<=n; i++) fact[i] = fact[i-1]*i%p;
    invf[n] = qpow(fact[n], p-2);
    for (int i=n; i; i--) invf[i-1] = invf[i]*i%p;
}

ll c(int n, int m) {return fact[n]*invf[m]%p*invf[n-m]%p;}

ll inv(int n) {return invf[n]*fact[n-1]%p;}

int main() {
    freopen("graph.in", "r", stdin);
    freopen("graph.out", "w", stdout);

    scanf("%d %d", &n, &p);
    initFact(n*n);

    f[1][0] = 0;
    for (int i=2; i<=n; i++) {
        for (int j=1; j<i; j++) {
            INC(f[i][j*j+(i-j)*(i-j)], c(i-1, j-1));
            for (int k=0; k<j*j; k++) {
                INC(f[i][k+(i-j)*(i-j)], (p-c(i-1, j-1)*f[j][k]%p)%p);
            }
        }
    }

    ll ans=0;
    for (int i=0; i<n*n; i++) {
        INC(ans, f[n][i]*n%p*n%p*inv(n*n-i)%p);
    }
    printf("%lld\n", ans);

    fclose(stdin);
    fclose(stdout);
    return 0;
}
